# 类
import pytest


# class Test001:
#     def test_001(self,login):
#         print("添加成员")
#     def test_002(self):
#         print("删除成员")
# def test_003(login):
#     print("添加用户")

# fixture修饰函数返回值

# import pytest
#
# @pytest.fixture
# def login_data():
#     print("登录")
#     yield ["admin","123456"]
#     print("退出登录")
# def test_001(login_data):
#     print("添加成员")
#     print(type(login_data))
#     print(f"用户名:{login_data[0]},密码:{login_data[1]}")
# @pytest.fixture
# def login_data1():
#     print("登录")
#     # yield
#     print("退出登录")
#     return {"user":"admin","pwd":"123456"}
# def test_002(login_data1):
#     print("添加成员")
#     print(type(login_data1))
#     print(f"用户名:{login_data1['user']},密码:{login_data1['pwd']}")

# 数据驱动模型

import pytest

@pytest.fixture(params=[{"user":"admin","pwd":"123"},
                        {"user":"admin1","pwd":"1231"},
                        {"user":"admin2","pwd":"1232"}])
def login(request):
    print("登录")
    return request.param  #"测试的数据"
def test_001(login):
    print(f"测试用例 测试用户名{login['user']} 密码{login['pwd']} 登录测试")

@pytest.fixture(params=[["admin","123","登录成功"],
                        ["admin1","1231","登录失败"],
                        ["admin2","1232","登录失败"]])
def login1(request):
    print("登录")
    return request.param  #"测试的数据"
def test_002(login1):
    print(f"--测试用例 测试用户名{login1[0]} 密码{login1[1]} 登录测试----")
    assert login1[2] == "登录成功" if login1[0] == "admin" and login1[1] == "123" else login1[2] == "登录失败"